<%--
  Created by IntelliJ IDEA.
  User: lingshao
  Date: 2020/9/15
  Time: 19:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>学员成绩表</title>
    <link rel="stylesheet" href="../layui/layui/css/layui.css" media="all">

    <script src="../layui/layui/layui.js"></script>
    <style type="text/css">
        *{
            font-size: 20px;
            font-family: 微软雅黑;
        }
    </style>
</head>
<body>

<blockquote class="layui-elem-quote news_search">

    <%--展示表格--%>
    <table id="demo" lay-filter="test"></table>
</blockquote>

<script>
    layui.use('table', function(){
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#demo'
            ,height:550
            ,cellMinWidth: 80
            ,url: '../ForeStudentGradeServlet?method=findGrade' //数据接口
            , limits: [5,10,15,20]  //一页选择显示3,5或10条数据
            , limit: 5  //一页显示10条数据
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                var result;
                console.log(this);
                console.log(JSON.stringify(res));
                if (this.page.curr) {
                    result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                }
                else {
                    result = res.data.slice(0, this.limit);
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": result //解析数据列表
                };
            }
            ,cols: [[ //表头
                {field: 'scoreId', title: '序号', align:'center', fixed: 'left'}
                ,{field: 'courseName', title: '科目名称',align:'center'}
                ,{field: 'grades', title: '分数',align:'center'}
                ,{field: 'examDate', title: '考试时间',align:'center'}
            ]]
            ,page:true
        });

    });
</script>
</body>
</html>